package com.ruoyi.procurement.design;

import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.procurement.domain.ProcurementModel;
import com.ruoyi.procurement.domain.ProcurementOrder;
import com.ruoyi.procurement.mapper.ProcurementOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public abstract class ProcurementStateHandlerAbs implements ProcurementStateHandler {

    @Override
    public String get() {
        throw new ServiceException("未找到对应的状态流转中心！");
    }

    @Autowired
    private ProcurementOrderMapper procurementOrderMapper;



    @Override
    public Integer handler(Long orderID, String state) {
        // 获取对应的订单
        ProcurementOrder procurementOrder = procurementOrderMapper.selectProcurementById(orderID);
        // 操作库存
        operationWareHousing(procurementOrder);
        // 操作库存记录
        operationModel();
        // 状态流转
        return transferTo(procurementOrder, state);
    }
    // 状态流转
    public abstract Integer transferTo(ProcurementOrder procurementOrder, String state);
    // 操作库存
    public abstract void operationWareHousing(ProcurementOrder procurementOrder);
    // 操作库存记录
    public void operationModel(){}
}
